Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default for env in KedroContext #3958

Closed
wants to merge 2 commits into from
Closed

Conversation

ankatiyar
Copy link
Contributor

@ankatiyar ankatiyar commented Jun 18, 2024

Description

Fix #3954

Development notes

I checked the test with Kedro 0.18.14 and it was still working. The test breaks from 0.19 with this change - #3300

Add a default value None to env.

Developer Certificate of Origin

We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a Signed-off-by line in the commit message. See our wiki for guidance.

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

Checklist

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (DCO)
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

Signed-off-by: Ankita Katiyar <ankitakatiyar2401@gmail.com>
@ankatiyar ankatiyar changed the title Add default for env Add default for env in KedroContext Jun 19, 2024
@ankatiyar ankatiyar marked this pull request as ready for review June 19, 2024 09:09
@ankatiyar ankatiyar requested a review from merelcht as a code owner June 19, 2024 09:09
@ankatiyar ankatiyar requested review from noklam and merelcht and removed request for merelcht June 19, 2024 09:09
@yury-fedotov
Copy link
Contributor

Thanks for looking into this!

@ankatiyar
Copy link
Contributor Author

@yury-fedotov Thanks for reporting the issue :)

Copy link
Contributor

@noklam noklam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I overlooked this. Can we keep the change at the same line? This is changing the order of arguments, is it needed?

@ankatiyar
Copy link
Contributor Author

Thanks! I overlooked this. Can we keep the change at the same line? This is changing the order of arguments, is it needed?

@noklam It was erroring out saying arguments with default values cannot be before ones without default values

@merelcht
Copy link
Member

Thanks! I overlooked this. Can we keep the change at the same line? This is changing the order of arguments, is it needed?

@noklam It was erroring out saying arguments with default values cannot be before ones without default values

Unfortunately, changing the order of arguments is a breaking change. So in this case it's better to ignore the error about argument order instead.

Signed-off-by: Ankita Katiyar <ankitakatiyar2401@gmail.com>
@ankatiyar
Copy link
Contributor Author

I've gone back to the original order but added default values to subsequent arguments. Not sure if this has any implications but the tests seem to be passing. The other way to fix the issue linked would be to change the example test in starters. WDYT? 🤔 @noklam @merelcht

@noklam
Copy link
Contributor

noklam commented Jun 21, 2024

    env: str | None = field(init=True, default=None)
    _package_name: str = field(init=True, default="")
    _hook_manager: PluginManager | None = field(init=True, default=None)

Unfortunately I think there is no nice solution here. ^ I don't think there should be a default for hook_manager, does it even work when it is None?

For package_name, I did a quick search and find no reference, I don't really know why it is needed. The problem is we cannot add a default for env without also adding default for all subsequent arguments. If we add default to all of them it's also a breaking change. (adding only to env is OK because I consider that's a bug fix, but it's not possible as mentioned).

My suggestion is not to fix anything in kedro, but remove the test. In fact, I don't think the KedroContext has any use in tests. In a standard kedro run, we should create the session and let the session to create context, runner, config_loader etc. However, in our test template, we created the config loader and runner manually. In addition, the context actually use the real hooks, but the tests that created run with no hook, so they are not consistent at all.

In our own testing docs, KedroContext is not mentioned at all.

@ankatiyar
Copy link
Contributor Author

@noklam yeah, i'll add your comment to the issue and put that in backlog and close this PR for now!

@ankatiyar ankatiyar closed this Jun 21, 2024
@ankatiyar ankatiyar deleted the default-env-context branch June 21, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite starter tests + update docs
4 participants